package com.itwn.portal.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.itwn.portal.reult.ResponseResult;
import com.itwn.portal.service.HistoryService;
import com.itwn.portal.vo.UserHistoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;
import java.util.List;

/**
 * @author cx
 * @date 2022/2/26
 * @apiNote
 */
@RestController
@RequestMapping("history")
public class HistoryController {

    @Autowired
    HistoryService historyService;

    @RequestMapping("/getUsrHistory")
    @ResponseBody
    public ResponseResult<UserHistoryVo> getUserHistory(Integer uid,Integer rid){
        ResponseResult<UserHistoryVo>  result = new ResponseResult<>();
        try{
            UserHistoryVo vo = this.historyService.getHistory(uid,rid);

            result.setMsg("查询成功!");
            result.setCode(200);
            result.setData(vo);
        } catch (Exception e) {
            e.printStackTrace();
            result.setMsg("查询失败!");
            result.setCode(201);
        }
        return result;
    }

}
